/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    can.h
  * @brief   This file contains all the function prototypes for
  *          the can.c file
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CAN_H__
#define __CAN_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */
#include <stm32f1xx.h>
/* USER CODE END Includes */

extern CAN_HandleTypeDef hcan;

/* USER CODE BEGIN Private defines */
#define	CAN_TX_EVENT_MAILBOX0_EMPTY			(1)
#define	CAN_TX_EVENT_MAILBOX1_EMPTY			(1 << 1)
#define	CAN_TX_EVENT_MAILBOX2_EMPTY			(1 << 2)

typedef struct
{
	CAN_TxHeaderTypeDef TxHeader;
	uint8_t Data[8];
} CanTxMsg;


#define	CAN_TX_MSG_MAX_NUM					5
#define	CAN_TX_MSG_POOL_SIZE				((sizeof(CanTxMsg) + sizeof(void *)) * CAN_TX_MSG_MAX_NUM)



/* USER CODE END Private defines */

void MX_CAN_Init(void);

/* USER CODE BEGIN Prototypes */

extern struct rt_thread CanTxThread;
extern char CanTxThreadStack[512];
extern struct rt_messagequeue CanTxMsgQueue;
extern uint8_t CanTxMsgPool[CAN_TX_MSG_POOL_SIZE];

void USER_CAN_Init(void);
void CreateCanMsgTxRequestLindeHeartbeat(CanTxMsg *pMsg);
void CreateCanMsgTxRequestLindeLockState(CanTxMsg *pMsg);
void CreateCanMsgTxRequestLindeCardInfo(CanTxMsg *pMsg);
void CanTxThreadEntry(void *param);
/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /* __CAN_H__ */

